<p>Exceptions are meant to represent the application’s state at the point at which an error occurred.</p>
<p>Making all fields in an <code>Exception</code> class <code>final</code> ensures that this state:</p>
<ul>
  <li> Will be fully defined at the same time the <code>Exception</code> is instantiated. </li>
  <li> Won’t be updated or corrupted by a questionable error handler. </li>
</ul>
<p>This will enable developers to quickly understand what went wrong.</p>
<h2>Noncompliant Code Example</h2>
<pre>
public class MyException extends Exception {

  private int status;                               // Noncompliant

  public MyException(String message) {
    super(message);
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

}
</pre>
<h2>Compliant Solution</h2>
<pre>
public class MyException extends Exception {

  private final int status;

  public MyException(String message, int status) {
    super(message);
    this.status = status;
  }

  public int getStatus() {
    return status;
  }

}
</pre>

